import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from "axios";
import ElementUI from "element-ui";
import './assets/global.css';
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false
Vue.prototype.axios = axios
Vue.use(ElementUI, { size: "small" });
//=======================让请求标头荷载token======================
axios.interceptors.request.use(config => {
  config.headers['Content-Type'] = 'application/json;charset=utf-8';
  // let user = localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : null
  // if (user) {
  //   config.headers['token'] = user.token;  // 设置请求头
  // }
  let token = localStorage.getItem("token")
  if (token) {
    config.headers['token'] = token;  // 设置请求头
  }
  return config
}, error => {
  return Promise.reject(error)
});
//=============================================================
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

